/*
 *
 *    Copyright (c) 2022 Project CHIP Authors
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

// THIS FILE IS GENERATED BY ZAP
// This file is generated from clusters-Structs.ipp.zapt

#include <clusters/ZoneManagement/Structs.h>

#include <app/data-model/StructDecodeIterator.h>
#include <app/data-model/WrappedStructEncoder.h>

namespace chip
{
namespace app
{
	namespace Clusters
	{
		namespace ZoneManagement
		{
			namespace Structs
			{

				namespace TwoDCartesianVertexStruct
				{
					CHIP_ERROR Type::Encode(TLV::TLVWriter &aWriter, TLV::Tag aTag) const
					{
						DataModel::WrappedStructEncoder encoder{ aWriter, aTag };
						encoder.Encode(to_underlying(Fields::kX), x);
						encoder.Encode(to_underlying(Fields::kY), y);
						return encoder.Finalize();
					}

					CHIP_ERROR DecodableType::Decode(TLV::TLVReader &reader)
					{
						detail::StructDecodeIterator __iterator(reader);
						while (true) {
							uint8_t __context_tag = 0;
							CHIP_ERROR err = __iterator.Next(__context_tag);
							VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV,
									    CHIP_NO_ERROR);
							ReturnErrorOnFailure(err);

							if (__context_tag == to_underlying(Fields::kX)) {
								err = DataModel::Decode(reader, x);
							} else if (__context_tag == to_underlying(Fields::kY)) {
								err = DataModel::Decode(reader, y);
							}

							ReturnErrorOnFailure(err);
						}
					}

				} // namespace TwoDCartesianVertexStruct

				namespace TwoDCartesianZoneStruct
				{
					CHIP_ERROR Type::Encode(TLV::TLVWriter &aWriter, TLV::Tag aTag) const
					{
						DataModel::WrappedStructEncoder encoder{ aWriter, aTag };
						encoder.Encode(to_underlying(Fields::kName), name);
						encoder.Encode(to_underlying(Fields::kUse), use);
						encoder.Encode(to_underlying(Fields::kVertices), vertices);
						encoder.Encode(to_underlying(Fields::kColor), color);
						return encoder.Finalize();
					}

					CHIP_ERROR DecodableType::Decode(TLV::TLVReader &reader)
					{
						detail::StructDecodeIterator __iterator(reader);
						while (true) {
							uint8_t __context_tag = 0;
							CHIP_ERROR err = __iterator.Next(__context_tag);
							VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV,
									    CHIP_NO_ERROR);
							ReturnErrorOnFailure(err);

							if (__context_tag == to_underlying(Fields::kName)) {
								err = DataModel::Decode(reader, name);
							} else if (__context_tag == to_underlying(Fields::kUse)) {
								err = DataModel::Decode(reader, use);
							} else if (__context_tag == to_underlying(Fields::kVertices)) {
								err = DataModel::Decode(reader, vertices);
							} else if (__context_tag == to_underlying(Fields::kColor)) {
								err = DataModel::Decode(reader, color);
							}

							ReturnErrorOnFailure(err);
						}
					}

				} // namespace TwoDCartesianZoneStruct

				namespace ZoneInformationStruct
				{
					CHIP_ERROR Type::Encode(TLV::TLVWriter &aWriter, TLV::Tag aTag) const
					{
						DataModel::WrappedStructEncoder encoder{ aWriter, aTag };
						encoder.Encode(to_underlying(Fields::kZoneID), zoneID);
						encoder.Encode(to_underlying(Fields::kZoneType), zoneType);
						encoder.Encode(to_underlying(Fields::kZoneSource), zoneSource);
						encoder.Encode(to_underlying(Fields::kTwoDCartesianZone),
							       twoDCartesianZone);
						return encoder.Finalize();
					}

					CHIP_ERROR DecodableType::Decode(TLV::TLVReader &reader)
					{
						detail::StructDecodeIterator __iterator(reader);
						while (true) {
							uint8_t __context_tag = 0;
							CHIP_ERROR err = __iterator.Next(__context_tag);
							VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV,
									    CHIP_NO_ERROR);
							ReturnErrorOnFailure(err);

							if (__context_tag == to_underlying(Fields::kZoneID)) {
								err = DataModel::Decode(reader, zoneID);
							} else if (__context_tag == to_underlying(Fields::kZoneType)) {
								err = DataModel::Decode(reader, zoneType);
							} else if (__context_tag ==
								   to_underlying(Fields::kZoneSource)) {
								err = DataModel::Decode(reader, zoneSource);
							} else if (__context_tag ==
								   to_underlying(Fields::kTwoDCartesianZone)) {
								err = DataModel::Decode(reader, twoDCartesianZone);
							}

							ReturnErrorOnFailure(err);
						}
					}

				} // namespace ZoneInformationStruct

				namespace ZoneTriggerControlStruct
				{
					CHIP_ERROR Type::Encode(TLV::TLVWriter &aWriter, TLV::Tag aTag) const
					{
						DataModel::WrappedStructEncoder encoder{ aWriter, aTag };
						encoder.Encode(to_underlying(Fields::kZoneID), zoneID);
						encoder.Encode(to_underlying(Fields::kInitialDuration),
							       initialDuration);
						encoder.Encode(to_underlying(Fields::kAugmentationDuration),
							       augmentationDuration);
						encoder.Encode(to_underlying(Fields::kMaxDuration), maxDuration);
						encoder.Encode(to_underlying(Fields::kBlindDuration), blindDuration);
						encoder.Encode(to_underlying(Fields::kSensitivity), sensitivity);
						return encoder.Finalize();
					}

					CHIP_ERROR DecodableType::Decode(TLV::TLVReader &reader)
					{
						detail::StructDecodeIterator __iterator(reader);
						while (true) {
							uint8_t __context_tag = 0;
							CHIP_ERROR err = __iterator.Next(__context_tag);
							VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV,
									    CHIP_NO_ERROR);
							ReturnErrorOnFailure(err);

							if (__context_tag == to_underlying(Fields::kZoneID)) {
								err = DataModel::Decode(reader, zoneID);
							} else if (__context_tag ==
								   to_underlying(Fields::kInitialDuration)) {
								err = DataModel::Decode(reader, initialDuration);
							} else if (__context_tag ==
								   to_underlying(Fields::kAugmentationDuration)) {
								err = DataModel::Decode(reader, augmentationDuration);
							} else if (__context_tag ==
								   to_underlying(Fields::kMaxDuration)) {
								err = DataModel::Decode(reader, maxDuration);
							} else if (__context_tag ==
								   to_underlying(Fields::kBlindDuration)) {
								err = DataModel::Decode(reader, blindDuration);
							} else if (__context_tag ==
								   to_underlying(Fields::kSensitivity)) {
								err = DataModel::Decode(reader, sensitivity);
							}

							ReturnErrorOnFailure(err);
						}
					}

				} // namespace ZoneTriggerControlStruct
			} // namespace Structs
		} // namespace ZoneManagement
	} // namespace Clusters
} // namespace app
} // namespace chip
